// models/user.go
package model

import (
	"encoding/json"
	"time"
)

type User struct {
	Account        string    `json:"account" gorm:"primaryKey"`
	Nickname       string    `json:"nickname"`
	Phone          string    `json:"phone"`
	Email          string    `json:"email"`
	SaltedPassword string    `json:"-"` // 使用 - 在JSON序列化时忽略该字段
	Salt           string    `json:"-"`
	CreditScore    int       `json:"credit_score" gorm:"default:100"`
	Status         int8      `json:"status" gorm:"default:1"`
	CreatedAt      time.Time `json:"created_at" gorm:"autoCreateTime"`
	UpdatedAt      time.Time `json:"updated_at" gorm:"autoUpdateTime"`
}

type Reviewer struct {
	Account        string          `json:"account" gorm:"primaryKey"`
	PendingReviews json.RawMessage `json:"pending_reviews"`
	User           User            `json:"-" gorm:"foreignKey:Account"` // 关联User表
}

func (u *User) TableName() string {
	return "user"
}

func (r *Reviewer) TableName() string {
	return "reviewer"
}
